import Vue from 'vue'
import VueRouter from 'vue-router'
import ManageHome from '../views/manage/ManageHome.vue'

Vue.use(VueRouter)

const routes = [
  //我的订单
  {
    path: '*',
    name: '404',
    component: () => import('../views/manage/NotFound.vue')
  },
  {
    path: '/manage',
    name: 'managehome',
    component: ManageHome,
    meta: {
      title: '逛淘吧管理员页面',
    },
    //重定向
    redirect: '/manage/main',
    children: [
      {
        path: 'main', //主页面区
        meta: {
          title: '逛淘吧管理员页面',
        },
        component: () => import('../views/manage/ManageMain.vue')
      },
      //商品列表
      {
        path: 'commodities',
        meta: {
          title: '逛淘吧管理员页面',
        },
        component: () => import('../views/manage/CommoditiesList.vue')
      },
      //待审核商品
      {
        path: 'unaprovecommodities',
        meta: {
          title: '逛淘吧管理员页面',
        },
        component: () => import('../views/manage/UnapproveCommodities.vue')
      },
      //买家列表
      {
        path: 'customers',
        meta: {
          title: '逛淘吧管理员页面',
        },
        component: () => import('../views/manage/CustomersList.vue')
      },
      //评论列表
      {
        path: 'reviews',
        meta: {
          title: '逛淘吧管理员页面',
        },
        component: () => import('../views/manage/ReviewsList.vue')
      },
      //用户列表
      {
        path: 'users',
        meta: {
          title: '逛淘吧管理员页面',
        },
        component: () => import('../views/manage/UsersList.vue')
      },
        //待审核用户
      {
        path: 'unapproveusers',
        meta: {
            title: '逛淘吧管理员页面',
        },
        component: () => import('../views/manage/UnapproveUsers.vue')
      }
    ]
  },
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/login/MyLogin.vue'),
    meta: {
      title: '逛淘吧登录页面',
    },
  },
  {
    path: '/retrievePassword',
    name: 'retrievePassword',
    meta: {
      title: '忘记密码',
    },
    component: () => import('../views/login/RetrievePassword.vue'),
  },
  {
    path: '/store',
    name: 'store',
    component: () => import('../views/shop/MyStore.vue'),
    redirect: '/store/ShopInfo',
    children: [{
      path: 'ShopInfo',
      name: 'comminfo',
      meta: { title: '商家管理页面' },
      component: () => import('../views/shop/ShopInfo.vue'),
    }, {
      path: 'ShopUp',
      name: 'routeName',
      meta: { title: '商家管理页面' },
      component: () => import('../views/shop/ShopUp.vue'),
    }, {
      path: 'ShopOrders',
      name: 'routeName',
      meta: { title: '商家管理页面' },
      component: () => import('../views/shop/ShopOrders.vue'),
    }, {
      path: 'ShopManage',
      name: 'routeName',
      meta: { title: '商家管理页面' },
      component: () => import('../views/shop/ShopManage.vue'),
    },]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next();
})
export default router
